<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<title>Acount Model Config</title>
	<jsp:include page="/core/tool/resources.jsp"></jsp:include>
	<script src="./modelconfig.js"></script>
</head>
<body>

	<div id="panel" class="easyui-panel" title="策略配置" style="width:100%" data-options="collapsible:true">
		<div id="toolbar">
		   <a class="easyui-linkbutton" iconCls='icon-save' onclick="click_save_model()">保存</a>
		   <a class="easyui-linkbutton" iconCls='icon-reload' onclick="loadData()">刷新</a>
	       <a class="easyui-linkbutton" iconCls="icon-ok"   onclick="click_run_all()">回测所有</a>
	       <a class="easyui-linkbutton" iconCls="icon-remove" onclick="click_delete_model()">删除模型</a>
		</div>
		<form id="ff" class="easyui-flexform" data-options="cellMargin:3,labelWidth:0,labelAlign:'right'">
			<div>
				<label>账户:</label>
		 		<div><input id="acountId" class="easyui-combobox"  name="acountId" 
		 			data-options="url:'../../base/acount/allparent.json',
		 				textField:'acountName',
		 				valueField:'acountId',
		 				onChange:changeAcount,
		 				loadFilter:function(data){return data.acounts},
		 				value:${acountId}"/></div>
		 	</div>		
			<div>
				<label>名称:</label>
				<div><input id="modelCode" class="easyui-combogrid" name="modelCode" 
    					data-options="required:true, panelWidth:550, idField:'code', textField:'name',
							    pagination:true, sortOrder:'asc', sortName:'name', rownumbers:true, fitColumns:true,
							    url:'../manage/modelquery.json',
							    columns:[[
							        {field:'code',title:'编码',width:60},
							        {field:'name',title:'名称',width:80},
							        {field:'strategyClass',title:'方法',width:160}
							    ]]"/></div>
		 	</div>
			<div>
				<label>开启日期:</label>
				<div><input class="easyui-datebox" name="startDate" required=true /></div>
		 	</div>
			<div>
				<label>结束日期:</label>
				<div><input class="easyui-datebox" name="endDate"/></div>
		 	</div>
			<div>
				<label>回测周期:</label>
				<div><input class="easyui-numberspinner" name="backTestPeriod" data-options="min:1, max:10"/></div>
		 	</div>
		 	<div>
				<label>自动交易:</label>
				<div><input class="easyui-combobox" name="tradeAuto" data-options="flexset:'BASE_TRUEFALSE'"/></div>
		 	</div>
			<div>
				<label>平时run:</label>
				<div><input class="easyui-combobox" name="runNomally" data-options="flexset:'BASE_TRUEFALSE'"/></div>
		 	</div>
			<div>
				<label>runCorn:</label>
				<div><input class="easyui-textbox" name="runCorn"/></div>
		 	</div>
			<div>
				<label>run间隔(m):</label>
				<div><input class="easyui-numberbox"  name="runInterval"/></div>
		 	</div>
			<div>
				<label>开启邮件:</label>
				<div><input class="easyui-combobox" name="sendEmail" data-options="flexset:'BASE_TRUEFALSE'"/></div>
		 	</div>
			<div colspan="3">
				<label>股票列表:</label>
				<div><input class="easyui-textbox" name="secList" data-options="height:50,multiline:true"/></div>
		 	</div>
		</form>  
	</div>
	<div style="height:5px"></div>

	<div id="toolbar2">
	   <a class="easyui-linkbutton" iconCls="icon-add" onclick="click_copy()">复制</a>
	   <a class="easyui-linkbutton" iconCls="icon-undo" onclick="$('#dg').edatagrid('cancelRow')">取消</a>
	   <a class="easyui-linkbutton" iconCls="icon-save" onclick="$('#dg').edatagrid('saveRow')">保存</a>
       <a class="easyui-linkbutton" iconCls="icon-ok"   onclick="click_run()">开始回测</a>   
	</div>

	<table id="dg" class="easyui-edatagrid" title="参数配置" style="width:100%"
            data-options="toolbar:'#toolbar2', editing:true, sortOrder:'asc', sortName:'acountId', rownumbers:true, singleSelect:true,collapsible:true,
           	 	updateUrl:'./savemodelparams.json', 
           	 	saveUrl:'./savemodelparams.json'">
        <thead>
            <tr>
            	<th data-options="field:'acountId', width:60">账户ID</th>
            	<th data-options="field:'acountName', width:100">账户名</th>
            	<th data-options="field:'lastBackTest', width:150,formconfig:{type:'datetimebox'}">上次回测</th>
            	<th data-options="field:'testingStatus', width:100">回测状态</th>
               	<c:forEach items="${params}" var="item" varStatus="status">
               		<th data-options="field:'${item.paramCode}', width:80
               			<c:if test="${item.configurable}">
               				,editor:'textbox'
               			</c:if>
               		"> ${item.paramName}</th>
			 	</c:forEach>
            </tr>
        </thead>
    </table>

</body>
</html>